#ifndef SOURCEMODEL_H
#define SOURCEMODEL_H

/*
 * tungvc :
 *
 */

#include <QObject>
#include <QtQml/qqml.h>
#include <QString>
#include <QAbstractListModel>
#include <QStringList>
#include "newspaper/sourcedetail.h"
#include <QtQml/qqml.h>


class SourceListModel : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(int count READ count )
public:
    enum SourceRoles {
        IdRole = Qt::UserRole + 1,
        NameRole ,
        ImageRole,
    };

    SourceListModel(QObject *parent = 0);
//![1]

    void addSourceInfo(const SourceInfo& sourceInfo);

    int rowCount(const QModelIndex & parent = QModelIndex()) const;

    int count();

    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;

    void setSourceInfo(const QList<SourceInfo>& listSourceInfo);

protected:
    QHash<int, QByteArray> roleNames() const;

private:
    QList<SourceInfo > m_listSourceInfo;
};


QML_DECLARE_TYPE(SourceListModel)

#endif //
